package cn.life.business.home.controller;

import cn.life.business.home.entity.Menu;
import cn.life.business.home.service.HomeService;
import cn.life.business.user.entity.vo.RegisterUserVo;
import cn.life.common.entity.model.CMessage;
import cn.life.common.entity.model.MyUser;
import cn.life.common.entity.model.MyUserInfo;
import cn.life.common.entity.po.ProjectPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author 李佳明
 * @Date 2018/11/29 0029.21:41.
 */
@RestController
@RequestMapping("home")
public class HomeController {

    /**
     *  首页Service
     */
    @Autowired
    private HomeService service;

    /**
     * @Description:    获取当前用户菜单
     *
     * @param myUserInfo
     * @return:
     *
     * @Author 李佳明
     * @Date 2018/7/5 0005 6:51
     */
    @PostMapping(value = "/menu")
    public CMessage queryHomeMenu(@MyUser MyUserInfo myUserInfo, @RequestBody ProjectPo projectPo){
        if(myUserInfo.getProjectId() == null){
            myUserInfo.setProjectId(projectPo.getProjectId());
        }
        if(myUserInfo.getProjectId() == null){
            return CMessage.fail("参数错误，请传递projectId");
        }
        return service.queryHomeMenu(myUserInfo);
    }
}
